//
//  FamilyHeartCenterView.swift
//  aj
//
//  Created by leeqb on 2/18/16.
//  Copyright © 2016 powerlee. All rights reserved.
//

import UIKit

class FamilyHeartCenterView: UIView {
    @IBOutlet weak var textLabel: UILabel!
    @IBOutlet var cntView: UIView!
    @IBOutlet weak var groupedIconView: GroupedIconView!
    
    var familyData: [NSObject : AnyObject]! {
        didSet {
            let userList = familyData["userList"] as? [[NSObject : AnyObject]]
            if userList?.count > 0 {
                self.hidden = false
                
                var imagePaths = [String]()
                var callNames = ""
                for i in 0...userList!.count - 1 {
                    if i > 0 && i < userList!.count {
                        callNames += ","
                    }
                    
                    let ele = userList![i]
                    imagePaths.append(ele["photo"] as? String ?? "")
                    if ele["callName"] is NSNull {
                        callNames += "我"
                    } else {
                        callNames += ele["callName"] as? String ?? ""
                    }
                }
                textLabel.text = callNames
                groupedIconView.imagePaths = imagePaths
            }
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.initSelf()
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        self.initSelf()
    }
    
    private func initSelf() {
        LX("FamilyHeartCenterView", owner: self)
        self.addSubview(cntView)
        //textLabel.text = "23213123"
        //self.hidden = true
    }
}
